package com.xu.cloud.service;

import com.xu.cloud.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class UserService {
    @Autowired
    @Qualifier("cloudConsumerRestTemplate")
    private RestTemplate restTemplate;
    // 调用cloud-provider的API接口
    public User getUserInfo() {
      String url = "http://cloud-provider/api/user/info";
//        String url = "http://localhost:1101/api/user/info";
        return restTemplate.getForObject(url, User.class);
    }
}
